package com.godpaper.the3directs.util
{
	import com.godpaper.the3directs.busniess.factorys.ButtonFactory;
	import com.godpaper.the3directs.model.BoardModel;
	import com.godpaper.the3directs.views.components.GasketButton;
	
	import de.polygonal.ds.Graph;
	import de.polygonal.ds.GraphNode;
	import de.polygonal.ds.Iterator;

	public class DebugUtil
	{
		/**
		 * Prints out all elements (for debug/demo purposes).
		 * 
		 * @return A human-readable representation of the structure.
		 */
		public static const TYPE_RED:String = "Red";
		public static const TYPE_BLUE:String = "Blue"; 
		public static function dumpGameGraph(type:String=null):String
		{
			var s:String = "GameGraph\n{";
			var iterator:Iterator;
			var currentGameGraph:Graph;
			if(type==TYPE_BLUE)
			{
				iterator = BoardModel.getInstance().gameGraphBlue.getIterator();
				currentGameGraph = BoardModel.getInstance().gameGraphBlue;
			}else if(type==TYPE_RED)
			{
				iterator = BoardModel.getInstance().gameGraphRed.getIterator();
				currentGameGraph = BoardModel.getInstance().gameGraphRed;
			}else
			{
				iterator = BoardModel.getInstance().gameGraph.getIterator();
				currentGameGraph = BoardModel.getInstance().gameGraph;
			}
			 
			var graphNode:GraphNode;
			while(iterator.hasNext())
			{
				s += "\n" + "\t";
				graphNode = iterator.data; 
				s += "graphNode.data.name:"+(graphNode.data as GasketButton).name+",position:["+(graphNode.data as GasketButton).position+"]";
				s += "\n" + "\t" + "{"+"\n";
				var r1:Number = PositionTransactUtil.transactArray2Index((graphNode.data as GasketButton).position);
				for(var i:int=0;i<ButtonFactory.MAX_GASKET_NUM;i++)
				{
					s += "\t"+ "\t"+"getArc["+r1+","+i+":"+currentGameGraph.getArc( r1,i)+"]"+"\n";
				}
				s += "\t" + "}";
				iterator.next();	
			}
			s += "\n"+"}";
			return s;
		}
	}
}